package com.ruoyi.liangshi.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.liangshi.domain.ArchItem;
import com.ruoyi.liangshi.mapper.AtchItemMapper;
import com.ruoyi.liangshi.service.IBiBsKscService;
import com.ruoyi.liangshi.service.IBizBsOrderService;
import com.ruoyi.liangshi.domain.BizBsOrder;
import com.ruoyi.liangshi.mapper.BizBsOrderMapper;
import com.ruoyi.liangshi.service.IBizBsOrderService;
import com.ruoyi.liangshi.vo.query.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;

/**
 * 门店营业收银订单信息Service业务层处理
 * 
 * @author ruoyi
 * @date 2023-11-18
 */
@Service
public class BizBsOrderServiceImpl extends ServiceImpl<BizBsOrderMapper, BizBsOrder> implements IBizBsOrderService{
    @Autowired
    private BizBsOrderMapper bizBsOrderMapper;

    @Autowired
    private IBiBsKscService biBsKscService;


    @Value("${arch-item.excluds}")
    private String archItemExcluds;

    @Override
    public Integer getTimeOutOrders(OrderAndKscCommonQueryVo orderAndKscCommonQueryVo) {
        return bizBsOrderMapper.getTimeOutOrders(orderAndKscCommonQueryVo);
    }

    @Override
    public List<BiBsKscDataVo> getKscDataList(OrderAndKscCommonQueryVo orderAndKscCommonQueryVo) {
        List<String> excludeItemIds = Arrays.asList(archItemExcluds.split(","));
        orderAndKscCommonQueryVo.setExcludeItemIds(excludeItemIds);
        return bizBsOrderMapper.getKscDataList(orderAndKscCommonQueryVo);
    }

    @Override
    public BiBsOrderDataInfoVo getOrderDataInfo(OrderAndKscCommonQueryVo orderAndKscCommonQueryVo) {
        List<String> excludeItemIds = Arrays.asList(archItemExcluds.split(","));
        orderAndKscCommonQueryVo.setExcludeItemIds(excludeItemIds);
        // 计算菜品数量
        BiBsOrderDataInfoVo biBsOrderDataInfoVo = biBsKscService.getOrderKscInfo(orderAndKscCommonQueryVo);
        if(biBsOrderDataInfoVo==null){
            biBsOrderDataInfoVo = new  BiBsOrderDataInfoVo();
            return biBsOrderDataInfoVo ;
        }
        // 计算订单数量
        Integer orderCount = bizBsOrderMapper.getOrderDataInfo(orderAndKscCommonQueryVo);
        if(orderCount==null){
            orderCount =0 ;
        }
        biBsOrderDataInfoVo.setTotalOrderCount(orderCount);
        return biBsOrderDataInfoVo ;
    }

    @Override
    public List<BiBsOrderDeptDashboardDataVo> getBiBsOrderDeptDashboardData(String type) {
        return bizBsOrderMapper.getBiBsOrderDeptDashboardData(type);
    }

    @Override
    public BiBsOrderDashboardDataVo getBiBsOrderDashboardData() {
        return bizBsOrderMapper.getBiBsOrderDashboardData();
    }

    /**
     * 查询门店营业收银订单信息
     * 
     * @param id 门店营业收银订单信息主键
     * @return 门店营业收银订单信息
     */
    @Override
    public BizBsOrder selectBizBsOrderById(Long id)
    {
        return bizBsOrderMapper.selectBizBsOrderById(id);
    }

    /**
     * 查询门店营业收银订单信息列表
     * 
     * @param bizBsOrder 门店营业收银订单信息
     * @return 门店营业收银订单信息
     */
    @Override
    public List<BizBsOrder> selectBizBsOrderList(BizBsOrder bizBsOrder)
    {
        return bizBsOrderMapper.selectBizBsOrderList(bizBsOrder);
    }

    /**
     * 新增门店营业收银订单信息
     * 
     * @param bizBsOrder 门店营业收银订单信息
     * @return 结果
     */
    @Override
    public int insertBizBsOrder(BizBsOrder bizBsOrder)
    {
        return bizBsOrderMapper.insertBizBsOrder(bizBsOrder);
    }

    /**
     * 修改门店营业收银订单信息
     * 
     * @param bizBsOrder 门店营业收银订单信息
     * @return 结果
     */
    @Override
    public int updateBizBsOrder(BizBsOrder bizBsOrder)
    {
        return bizBsOrderMapper.updateBizBsOrder(bizBsOrder);
    }

    /**
     * 批量删除门店营业收银订单信息
     * 
     * @param ids 需要删除的门店营业收银订单信息主键
     * @return 结果
     */
    @Override
    public int deleteBizBsOrderByIds(Long[] ids)
    {
        return bizBsOrderMapper.deleteBizBsOrderByIds(ids);
    }

    /**
     * 删除门店营业收银订单信息信息
     * 
     * @param id 门店营业收银订单信息主键
     * @return 结果
     */
    @Override
    public int deleteBizBsOrderById(Long id)
    {
        return bizBsOrderMapper.deleteBizBsOrderById(id);
    }
}
